home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-1.iso / comm / 110a115a.zip / WINHOST.ZIP / WCONFIG.SLT < prev    next >
Text File  |  1995-12-22  |  7KB  |  248 lines

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. //   W C O N F I G . S L T
  4. //
  5. //   Copyright (C) 1988,1989,1990,1991 Exis Inc.
  6. //   Copyright (C) 1994 deltaComm Development, Inc.
  7. //
  8. //   - Written by Colin Sampaleanu.
  9. //   - Modifications by Jeff Woods, Feb '91, to add help function and support
  10. //     for locked modems.
  11. //   - Modifications for Telix for Windows July '94
  12. //   - Modifications to user interface Dec '94 by Sean Palmer
  13. //   - More modifications to user interface Mar '95 by Jeff Smith
  14. //
  15. //   This is a Host Mode configuration script for Telix for Windows.
  16. //   It reads from and saves parameters to the file WINHOST.CNF.
  17. //
  18. //////////////////////////////////////////////////////////////////////////////
  19.  
  20. str host_downloads[64],
  21.     host_uploads[64],
  22.     host_message[64],
  23.     our_dir[64];
  24. int modem_lock = 0,
  25.     direct_connect = 0,
  26.     closed_sys = 0,
  27.     temp_var;
  28.  
  29. #INCLUDE "WHUTILS.SLT"
  30.  
  31. //////////////////////////////////////////////////////////////////////////////
  32.  
  33. main() {
  34.  
  35.   get_our_dir();
  36.   read_host_config_file();
  37.   host_configure();
  38.  
  39. }
  40.  
  41.  
  42. //////////////////////////////////////////////////////////////////////////////
  43.  
  44. host_configure() {
  45.  
  46.   str s[200];
  47.   int c, f, i, stat;
  48.   int lnum, inp, old_lnum;
  49.   str hold_line[75];
  50.  
  51.   lnum=old_lnum=10;
  52.   if (!host_downloads) {
  53.     if (getenv ("HOST2DIR", s) != 0) {
  54.       host_downloads = our_dir;
  55.       strcat (host_downloads, "XFER\");
  56.     }
  57.     else {
  58.       host_downloads = _telix_dir;
  59.       strcat(host_downloads, "HOSTDOWN\");
  60.     }
  61.   }
  62.  
  63.   if (!host_uploads) {
  64.     if (getenv ("HOST2DIR", s) != 0) {
  65.       host_uploads = our_dir;
  66.       strcat (host_uploads, "XFER\");
  67.     }
  68.     else {
  69.       host_uploads = _telix_dir;
  70.       strcat(host_uploads, "HOSTDOWN\");
  71.     }
  72.   }
  73.  
  74.   if (!host_message) {
  75.     if (getenv ("HOST2DIR", s) != 0) {
  76.       host_uploads = our_dir;
  77.     }
  78.     else {
  79.       host_message = _telix_dir;
  80.       strcat(host_message, "HOSTMSG\");
  81.     }
  82.   }
  83.  
  84.   while (1) {
  85.     clear_scr ();
  86.     prints("^M^JWCONFIG - WinHost Mode Configuration Script^M^J");
  87.     printsc("     Host download directory: ");
  88.     prints(host_downloads);
  89.     printsc("     Host upload directory  : ");
  90.     prints(host_uploads);
  91.     printsc("     Host message directory : ");
  92.     prints(host_message);
  93.     printsc("     Connection type        : ");
  94.     if (direct_connect)
  95.       prints("Direct");
  96.     else
  97.       prints("Modem");
  98.     printsc("     Lock Speed (0=none)    : ");
  99.     printn(modem_lock); newline();
  100.     printsc("     Sign-up mode           : ");
  101.     if (closed_sys) {
  102.       prints ("Closed (users may not sign up on-line)");
  103.     }
  104.     else {
  105.       prints ("Open   (users may sign up on-line)");
  106.     }
  107.  
  108.     prints("^M^J     Exit without saving changes.");
  109.     prints("     Exit and save changes to disk.^M^J");
  110.     vgetchrs(2, lnum, hold_line, 0, 75);
  111.     vputchrs(2, lnum, hold_line, 0, 75, 16*_fore_color+_back_color);
  112.     vputchrs(2, lnum, "->", 0, 2, 16*_fore_color+_back_color);
  113.     do
  114.      {
  115.       if (subchr(hold_line, 3) != ' ')
  116.         inp=inkeyw();
  117.       if ((inp == 18432) or (inp == 19200)) lnum=lnum-1;
  118.       if ((inp == 20480) or (inp == 19712)) lnum=lnum+1;
  119.       if (lnum < 3) lnum = 3;
  120.       if (lnum > 11) lnum = 11;
  121.       vputchrs(2, old_lnum, hold_line, 0, 75, _fore_color+_back_color*16);
  122.       vgetchrs(2, lnum, hold_line, 0, 75);
  123.       vputchrs(2, lnum, hold_line, 0, 75, 16*_fore_color+_back_color);
  124.       vputchrs(2, lnum, "->", 0, 2, 16*_fore_color+_back_color);
  125.       old_lnum=lnum;
  126.      }
  127.     while ((inp != 13) and (inp != 32));
  128.  
  129.     c = lnum;
  130.  
  131.     if (c < 3 || c > 11)
  132.       continue;
  133.  
  134.     if (c >= 3 && c <= 6)
  135.       printsc("Enter new value (Esc to abort): ");
  136.  
  137.     if (c == 3) {
  138.       s = host_downloads;
  139.       stat = inputbox ("Host Download Directory", "Directory:", s);
  140.       if (stat == 1) {
  141.         host_downloads = s;
  142.         strupper(host_downloads);
  143.       }
  144.       if ((i = strlen(host_downloads)) != 0)       // add slash if needed
  145.         if (subchr(host_downloads, i - 1) != '\')
  146.           copystr("\", host_downloads, i, 1);
  147.     }
  148.  
  149.     else if (c == 4) {
  150.       s = host_uploads;
  151.       stat = inputbox ("Host Upload Directory", "Directory:", s);
  152.       if (stat == 1) {
  153.         host_uploads = s;
  154.         strupper(host_uploads);
  155.       }
  156.       if ((i = strlen(host_uploads)) != 0)
  157.         if (subchr(host_uploads, i - 1) != '\')
  158.         copystr("\", host_uploads, i, 1);
  159.     }
  160.  
  161.  
  162.     else if (c == 5) {
  163.       s = host_message;
  164.       stat = inputbox ("Host Message Directory", "Directory:", s);
  165.       if (stat == 1) {
  166.         host_message = s;
  167.         strupper(host_message);
  168.       }
  169.       if ((i = strlen(host_message)) != 0)
  170.         if (subchr(host_message, i - 1) != '\')
  171.         copystr("\", host_message, i, 1);
  172.     }
  173.  
  174.     else if (c == 6) {
  175.       direct_connect = ! direct_connect;
  176.     }
  177.  
  178.     else if (c == 7) {
  179.       itos(modem_lock, s);
  180.       inputbox ("Modem Lock Speed", "", s);
  181.       modem_lock = stoi(s);
  182.     }
  183.  
  184.     else if (c == 8) {
  185.       closed_sys = ! closed_sys;
  186.     }
  187.  
  188.     else if (c == 10) {
  189.       prints("^M^JWCONFIG done.^M^J");
  190.       return;
  191.     }
  192.  
  193.     else if (c == 11) {
  194.  
  195.       if (! check_directory (host_downloads)) {
  196.         s = host_downloads;
  197.         strcat (s, " does not exist^M^JHost will not run until its directories exist!");
  198.         msgbox ("Warning", s, 0);
  199.       }
  200.  
  201.       if ((strcmpi (host_downloads, host_uploads) != 0) && (! check_directory (host_uploads))) {
  202.         s = host_uploads;
  203.         strcat (s, " does not exist^M^JHost will not run until its directories exist!");
  204.         msgbox ("Warning", s, 0);
  205.       }
  206.  
  207.       if (! check_directory (host_message)) {
  208.         s = host_message;
  209.         strcat (s, " does not exist^M^JHost will not run until its directories exist!");
  210.         msgbox ("Warning", s, 0);
  211.       }
  212.  
  213.       s = our_dir;
  214.       strcat(s, "WINHOST.CNF");
  215.       f = fopen(s, "w");
  216.  
  217.       if (!f) {
  218.         printsc("Error writing to ");
  219.         printsc(s);
  220.         prints("!");
  221.         continue;
  222.       }
  223.  
  224.       fputs(host_downloads, f);
  225.       fputs("^M^J", f);
  226.       fputs(host_uploads, f);
  227.       fputs("^M^J", f);
  228.       fputs(host_message, f);
  229.       fputs("^M^J", f);
  230.       if (direct_connect)
  231.         fputs("Direct^M^J", f);
  232.       else
  233.         fputs("Modem^M^J", f);
  234.       itos(modem_lock, s);
  235.       fputs(s, f);
  236.       fputs("^M^J", f);
  237.       if (closed_sys)
  238.         fputs ("Closed", f);
  239.       else
  240.         fputs ("Open", f);
  241.  
  242.       prints("^M^JWCONFIG done.^M^J");
  243.       fclose(f);
  244.       return;
  245.     }
  246.   }
  247. }
  248.